<?php $mood_options[]='Humör';
foreach ($moods as $m) {
	$mood_options[$m->moodID]=$m->moodName;
}
$category_options[]='Kategorier';
foreach ($categories as $c) {
	$category_options[$c->categoryID]=$c->categoryName;
} ?>

<div id ="xml"> 
<?php echo anchor('site/export_xml', 'Exportera till XML'); ?>
</div>
	<div id ="xml"> 
	<?php echo anchor('site/import_xml', 'Importera till XML'); ?>
	</div>
	<div id ="rss"> 
	<?php 
	$data = '<img src="' . base_url() . 'img/rss.png" alt="" id="rss_image" />';
	echo anchor('feed', $data, 'title="RSS"'); ?>
	</div>

	<h1 id ="page_title">Klotterplanket</h1>
<div id="entries">
<ul>
<?php  if(isset($rows) && count($rows) > 0) : foreach($rows as $row) : ?>  
  <li class="
	<?php if($row->moodID=="1"){echo "glad";} 
		else if($row->moodID=="2"){echo "ledsen";} 
		else if($row->moodID=="3"){echo "arg";}
		else if($row->moodID=="4"){echo "irriterad";}?> ">  	
		<p class="headline"> <?php echo anchor("site/get_entry/$row->entryID", $row->headline); ?></p>
		<?php
		if($row->isImageEntry){
			$img_path = 'img/'. $row->imageURL;
			echo img($img_path);	
		}
		else{
			echo '<p class="text" >'. $row->text .'</p>';
			
		}
		 ?>
		<p class="author"> <?php echo $row->author; ?></p>
		<p class="categoryName"> <?php echo $row->categoryName; ?></p>
		<p class="moodName"> <?php echo $row->moodName; ?></p>
		<p class="edit"> <?php echo anchor("site/edit_entry/$row->entryID", 'Ändra'); ?></p>
	</li>
<?php endforeach; ?>
	<?php else : ?>	
		<h2>No records were returned.</h2>
	<?php endif; ?>
	</ul>
</div>


<div id="bottom_content">
<div id="add_form">
	<p id="klottra">Klottra</p>
	<?php
	echo form_submit('text','Text', 'id="text"');
	echo form_submit('image','Bild', 'id="image"');
	echo validation_errors(); 
	?>
</div>

<script type="text/javascript">
$('#text').click(function() {
	
	
	var form_data = {
		ajax: '1'		
	};
	
	$.ajax({
		url: "<?php echo site_url('site/text'); ?>",
		type: 'POST',
		data: form_data,
		success: function(msg) {
			$('#add_form').html(msg);
		}
	});
	
	return false;
});

$('#image').click(function() {
	
	
	var form_data = {
		ajax: '1'		
	};
	
	$.ajax({
		url: "<?php echo site_url('site/image'); ?>",
		type: 'POST',
		data: form_data,
		success: function(msg) {
			$('#add_form').html(msg);
		}
	});
	
	return false;
});
</script>


<div id="kontrollpanel">
	<p id="search">Sök</p>
	<?php 
	echo form_open('site/search_form');
	$data = array(
	'name'        => 'search_string',
	'placeholder' => 'Sök'
	);
	echo form_input($data);
	//echo form_dropdown('search_mood', $mood_options, 0);
	//echo form_dropdown('search_category', $category_options, 0);
	echo form_submit('search',  'Sök');
	echo form_close();
	?>
	
	


</div>
</div>

